package com.ruoyi.web.controller.fantasy;

import java.util.List;

import com.huanzhidadi.fantasy.bean.domain.FantasyShopItem;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.fantasy.service.IFantasyShopItemService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 商店道具关系 信息操作处理
 * 
 * @author wanghui
 * @date 2020-01-29
 */
@Controller
@RequestMapping("/fantasy/fantasyShopItem")
public class FantasyShopItemController extends BaseController
{
    private String prefix = "fantasy/fantasyShopItem";
	
	@Autowired
	private IFantasyShopItemService fantasyShopItemService;
	
	@RequiresPermissions("fantasy:fantasyShopItem:view")
	@GetMapping()
	public String fantasyShopItem()
	{
	    return prefix + "/fantasyShopItem";
	}
	
	/**
	 * 查询商店道具关系列表
	 */
	@RequiresPermissions("fantasy:fantasyShopItem:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(FantasyShopItem fantasyShopItem)
	{
		startPage();
        List<FantasyShopItem> list = fantasyShopItemService.selectFantasyShopItemList(fantasyShopItem);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出商店道具关系列表
	 */
	@RequiresPermissions("fantasy:fantasyShopItem:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(FantasyShopItem fantasyShopItem)
    {
    	List<FantasyShopItem> list = fantasyShopItemService.selectFantasyShopItemList(fantasyShopItem);
        ExcelUtil<FantasyShopItem> util = new ExcelUtil<FantasyShopItem>(FantasyShopItem.class);
        return util.exportExcel(list, "fantasyShopItem");
    }
	
	/**
	 * 新增商店道具关系
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存商店道具关系
	 */
	@RequiresPermissions("fantasy:fantasyShopItem:add")
	@Log(title = "商店道具关系", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(FantasyShopItem fantasyShopItem)
	{		
		return toAjax(fantasyShopItemService.insertFantasyShopItem(fantasyShopItem));
	}

	/**
	 * 修改商店道具关系
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Long id, ModelMap mmap)
	{
		FantasyShopItem fantasyShopItem = fantasyShopItemService.selectFantasyShopItemById(id);
		mmap.put("fantasyShopItem", fantasyShopItem);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存商店道具关系
	 */
	@RequiresPermissions("fantasy:fantasyShopItem:edit")
	@Log(title = "商店道具关系", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(FantasyShopItem fantasyShopItem)
	{		
		return toAjax(fantasyShopItemService.updateFantasyShopItem(fantasyShopItem));
	}
	
	/**
	 * 删除商店道具关系
	 */
	@RequiresPermissions("fantasy:fantasyShopItem:remove")
	@Log(title = "商店道具关系", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(fantasyShopItemService.deleteFantasyShopItemByIds(ids));
	}
	
}
